home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Blitter / DrawPixel.s < prev    next >
Text File  |  1997-12-15  |  3KB  |  141 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Draw Pixel
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;Draws a pixel on a screen without destroying the background.
  7.  
  8.     INCDIR    "GMSDev:Includes/"
  9.     INCLUDE    "dpkernel/dpkernel.i"
  10.  
  11.     SECTION    "DrawPixel",CODE
  12.  
  13. ;===========================================================================;
  14. ;                             INITIALISE DEMO
  15. ;===========================================================================;
  16.  
  17.     STARTDPK
  18.  
  19. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  20.     move.l    DPKBase(pc),a6
  21.     lea    FILE_Background(pc),a0    ;Load the picture.
  22.     moveq    #ID_PICTURE,d0
  23.     CALL    Load
  24.     move.l    d0,PIC_Background
  25.     beq.s    .Exit
  26.  
  27.     moveq    #ID_SCREEN,d0
  28.     CALL    Get
  29.     move.l    d0,Screen
  30.     beq.s    .Exit
  31.  
  32.     move.l    PIC_Background(pc),a0
  33.     move.l    Screen(pc),a1
  34.     move.l    PIC_Bitmap(a0),a2
  35.     move.l    BMP_Data(a2),GS_MemPtr1(a1)
  36.     CALL    CopyStructure
  37.  
  38.     move.l    Screen(pc),a0
  39.     sub.l    a1,a1
  40.     CALL    Init
  41.     tst.l    d0
  42.     beq.s    .Exit
  43.  
  44.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  45.     CALL    Get
  46.     move.l    d0,JoyData
  47.     beq.s    .Exit
  48.     move.l    d0,a0    ;Initialise the joydata structure.
  49.     sub.l    a1,a1
  50.     CALL    Init
  51.     tst.l    d0
  52.     beq.s    .Exit
  53.  
  54.     move.l    Screen(pc),a0
  55.     CALL    Display
  56.  
  57.     bsr.s    Main
  58.  
  59. .Exit    move.l    DPKBase(pc),a6
  60.     move.l    JoyData(pc),a0
  61.     CALL    Free
  62.     move.l    Screen(pc),a0
  63.     CALL    Free
  64.     move.l    PIC_Background(pc),a0
  65.     CALL    Free
  66.     MOVEM.L    (SP)+,A0-A6/D1-D7
  67.     moveq    #ERR_OK,d0
  68.     rts
  69.  
  70. ;===========================================================================;
  71. ;                                MAIN LOOP
  72. ;===========================================================================;
  73.  
  74. Main:    moveq    #100,d6
  75.     moveq    #100,d7
  76. .loop    move.l    BLTBase(pc),a6
  77.  
  78.     ;Replace the background pixel.
  79.  
  80.     move.l    Screen(pc),a0
  81.     move.l    GS_Bitmap(a0),a0
  82.     movem.w    OldPixel(pc),d1/d2/d3
  83.     tst.w    d3
  84.     blt.s    .read
  85.     CALL    bltDrawPixel    ;>> = Draw the old background pixel.
  86.  
  87.     ;Read the new background pixel.
  88.  
  89. .read    move.l    Screen(pc),a0
  90.     move.l    GS_Bitmap(a0),a0
  91.     move.w    d6,d1    ;d1 = X Coordinate.
  92.     move.w    d7,d2    ;d2 = Y Coordinate.
  93.     CALL    bltReadPixel    ;>> = Read the pixel.
  94.     movem.w    d6/d7,OldPixel    ;MA = Save coords of next pixel.
  95.     move.w    d0,OldPixel+4    ;MA = Save colour of next pixel.
  96.  
  97.     ;Draw the pixel.
  98.  
  99.     move.l    Screen(pc),a0
  100.     move.l    GS_Bitmap(a0),a0
  101.     move.w    d6,d1    ;d1 = X Coordinate.
  102.     move.w    d7,d2    ;d2 = Y Coordinate.
  103.     move.w    #3,d3    ;d3 = Colour.
  104.     CALL    bltDrawPixel    ;>> = Draw our pixel.
  105.  
  106.     move.l    SCRBase(pc),a6
  107.     CALL    scrWaitAVBL    ;>> = Wait for VBL.
  108.  
  109.     move.l    DPKBase(pc),a6
  110.     move.l    JoyData(pc),a0
  111.     CALL    Query
  112.     move.l    JoyData(pc),a0
  113.     add.w    JD_YChange(a0),d7
  114.     add.w    JD_XChange(a0),d6
  115.     move.l    JD_Buttons(a0),d0
  116.     btst    #JB_LMB,d0
  117.     beq.s    .loop
  118.     rts
  119.  
  120. OldPixel:
  121.     dc.w    0,0,-1
  122.  
  123. ;===========================================================================;
  124. ;                                  DATA
  125. ;===========================================================================;
  126.  
  127. JoyData:     dc.l  0
  128. Screen:         dc.l  0
  129. PIC_Background:     dc.l  0
  130. FILE_Background: FILENAME "GMS:demos/data/PIC.Green"
  131.  
  132. ;===========================================================================;
  133.  
  134. ProgName:    dc.b  "Draw Pixel",0
  135. ProgAuthor:    dc.b  "Paul Manias",0
  136. ProgDate:    dc.b  "14 December 1997",0
  137. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  138. ProgShort:    dc.b  "Pixel demonstration.",0
  139.         even
  140.  
  141.